package com.foreveross.crawl.vo;

import java.io.Serializable;

/**
 * 当前机器信息
 * @author luofangyi
 *
 */
public class MachineInfo implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 3272102507867597816L;
	
	private String ip;
	private int port;
	/**
	 * 操作系统类型
	 */
	private String osType;
	/**
	 * 操作系统版本
	 */
	private String osVersion;
	/**
	 * 操作系统架构
	 */
	private String osArch;
	/**
	 * mac地址
	 */
	private String macAddress;
	
	/** 可使用内存. */
    private long totalMemory;
    
    /** 剩余内存. */
    private long freeMemory;
    
    /** 最大可使用内存. */
    private long maxMemory;
        
    /** 总的物理内存. */
    private long totalMemorySize;
    
    /** 剩余的物理内存. */
    private long freePhysicalMemorySize;
    
    /** 已使用的物理内存. */
    private long usedMemory;
    
    /** 线程总数. */
    private int totalThread;
    
    /** cpu使用率. */
    private double cpuRatio;
    
	@Override
	public String toString() {
		return "MachineInfo [ip=" + ip + ", port=" + port + ", osType="
				+ osType + ", osVersion=" + osVersion + ", osArch=" + osArch
				+ ", macAddress=" + macAddress + ", totalMemory=" + totalMemory
				+ ", freeMemory=" + freeMemory + ", maxMemory=" + maxMemory
				+ ", totalMemorySize=" + totalMemorySize
				+ ", freePhysicalMemorySize=" + freePhysicalMemorySize
				+ ", usedMemory=" + usedMemory + ", totalThread=" + totalThread
				+ ", cpuRatio=" + cpuRatio + "]";
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		long temp;
		temp = Double.doubleToLongBits(cpuRatio);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		result = prime * result + (int) (freeMemory ^ (freeMemory >>> 32));
		result = prime
				* result
				+ (int) (freePhysicalMemorySize ^ (freePhysicalMemorySize >>> 32));
		result = prime * result + ((ip == null) ? 0 : ip.hashCode());
		result = prime * result
				+ ((macAddress == null) ? 0 : macAddress.hashCode());
		result = prime * result + (int) (maxMemory ^ (maxMemory >>> 32));
		result = prime * result + ((osArch == null) ? 0 : osArch.hashCode());
		result = prime * result + ((osType == null) ? 0 : osType.hashCode());
		result = prime * result
				+ ((osVersion == null) ? 0 : osVersion.hashCode());
		result = prime * result + port;
		result = prime * result + (int) (totalMemory ^ (totalMemory >>> 32));
		result = prime * result
				+ (int) (totalMemorySize ^ (totalMemorySize >>> 32));
		result = prime * result + totalThread;
		result = prime * result + (int) (usedMemory ^ (usedMemory >>> 32));
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		MachineInfo other = (MachineInfo) obj;
		if (Double.doubleToLongBits(cpuRatio) != Double
				.doubleToLongBits(other.cpuRatio))
			return false;
		if (freeMemory != other.freeMemory)
			return false;
		if (freePhysicalMemorySize != other.freePhysicalMemorySize)
			return false;
		if (ip == null) {
			if (other.ip != null)
				return false;
		} else if (!ip.equals(other.ip))
			return false;
		if (macAddress == null) {
			if (other.macAddress != null)
				return false;
		} else if (!macAddress.equals(other.macAddress))
			return false;
		if (maxMemory != other.maxMemory)
			return false;
		if (osArch == null) {
			if (other.osArch != null)
				return false;
		} else if (!osArch.equals(other.osArch))
			return false;
		if (osType == null) {
			if (other.osType != null)
				return false;
		} else if (!osType.equals(other.osType))
			return false;
		if (osVersion == null) {
			if (other.osVersion != null)
				return false;
		} else if (!osVersion.equals(other.osVersion))
			return false;
		if (port != other.port)
			return false;
		if (totalMemory != other.totalMemory)
			return false;
		if (totalMemorySize != other.totalMemorySize)
			return false;
		if (totalThread != other.totalThread)
			return false;
		if (usedMemory != other.usedMemory)
			return false;
		return true;
	}
	public String getIp() {
		return ip;
	}
	public void setIp(String ip) {
		this.ip = ip;
	}
	public int getPort() {
		return port;
	}
	public void setPort(int port) {
		this.port = port;
	}
	public String getOsType() {
		return osType;
	}
	public void setOsType(String osType) {
		this.osType = osType;
	}
	public String getOsVersion() {
		return osVersion;
	}
	public void setOsVersion(String osVersion) {
		this.osVersion = osVersion;
	}
	public String getOsArch() {
		return osArch;
	}
	public void setOsArch(String osArch) {
		this.osArch = osArch;
	}
	public String getMacAddress() {
		return macAddress;
	}
	public void setMacAddress(String macAddress) {
		this.macAddress = macAddress;
	}
	public long getTotalMemory() {
		return totalMemory;
	}
	public void setTotalMemory(long totalMemory) {
		this.totalMemory = totalMemory;
	}
	public long getFreeMemory() {
		return freeMemory;
	}
	public void setFreeMemory(long freeMemory) {
		this.freeMemory = freeMemory;
	}
	public long getMaxMemory() {
		return maxMemory;
	}
	public void setMaxMemory(long maxMemory) {
		this.maxMemory = maxMemory;
	}
	public long getTotalMemorySize() {
		return totalMemorySize;
	}
	public void setTotalMemorySize(long totalMemorySize) {
		this.totalMemorySize = totalMemorySize;
	}
	public long getFreePhysicalMemorySize() {
		return freePhysicalMemorySize;
	}
	public void setFreePhysicalMemorySize(long freePhysicalMemorySize) {
		this.freePhysicalMemorySize = freePhysicalMemorySize;
	}
	public long getUsedMemory() {
		return usedMemory;
	}
	public void setUsedMemory(long usedMemory) {
		this.usedMemory = usedMemory;
	}
	public int getTotalThread() {
		return totalThread;
	}
	public void setTotalThread(int totalThread) {
		this.totalThread = totalThread;
	}
	public double getCpuRatio() {
		return cpuRatio;
	}
	public void setCpuRatio(double cpuRatio) {
		this.cpuRatio = cpuRatio;
	}
}
